using System;
using System.Collections.Generic;

using RexToy.Compiler.Lexical;

namespace RexToy.Compiler.Semantic
{
    public abstract class SemanticParser<TTokenType, TAST>
    {
        protected int index;
        protected SemanticParser()
        {
        }

        protected List<Token<TTokenType>> tokens;
        public virtual void SetParseContent(List<Token<TTokenType>> tokens)
        {
            this.tokens = tokens;
            index = 0;
        }

        protected Token<TTokenType> PeekNextToken()
        {
            if (index == tokens.Count)
                return Token<TTokenType>.EndToken;
            return tokens[index];
        }

        protected Token<TTokenType> GetNextToken()
        {
            if (index == tokens.Count)
                return Token<TTokenType>.EndToken;
            return tokens[index++];
        }

        public abstract TAST Parse();
    }
}